#include<bits/stdc++.h>
using namespace std;

bool isoperator(char ch) {
    if(ch == '+' || ch == '-' || ch == '*' || ch == '/'|| ch == '('|| ch == ')'|| ch == '.')
        return true;
    return false; 
}

bool isnumber(char ch){
    if(ch >= '0' && ch <= '9')
        return true;
    return false; 
}

int getPriority(char ch) {
    int level = 0; 
    switch(ch) {
        case '(':
            level = 1;
            break;
        case '+':
        case '-':
            level = 2;
            break;
        case '*':
        case '/':
            level = 3;
            break;
        default:
            break;
    }
    return level;
}
string s;
string in;
stack <double> num;
stack <char> oper;
double nownum,n;
bool dot;

void push(){
    num.push(nownum);
    nownum=0;
    n=1;
    dot=0;
}
void pop(){
    double a, b, result;
	b = num.top(), num.pop();

	a = num.top(), num.pop();
	switch (oper.top()){
		case '+': result = a + b; break;
		case '-': result = a - b; break;
		case '*': result = a * b; break;
		case '/': if(b == 0) {
                cout << "除数不能为0。\n";
                exit(1); 
            }
            else
                result = a / b;
	}
	num.push(result), oper.pop();
}


double calculator(string s){
    while(!num.empty()) num.pop();
    while(!oper.empty()) oper.pop();
    in="";
	nownum = 0, n = 1;
	dot = 0;
    for(int i=0;i<s.length();i++){
        if(isoperator(s[i])||isnumber(s[i])) in=in+s[i];
    }
    if(in.length()==0) {cout<< "无有效数字,表达式无效\n" ;return 1; }
    for(int i=0;i<in.length();i++){
        char ch=in[i];
        if(ch<='9'&&ch>='0'){
            if(i!=0&&in[i-1]==')') {cout<< "表达式无效\n" ;return 1; }
            if(dot) n=n*0.1,nownum=nownum+(ch-'0')*n;

            else nownum=(ch-'0')+nownum*10;
            if(isoperator(in[i+1])&&(in[i+1]!='.')||i+1==in.length()) push();
        }
        else if(ch=='.'){
            if(dot==1){cout<< "一个数中存在两个小数点,表达式无效\n" ;return 1; }
            else dot=1;
            if(isoperator(in[i+1])||i+1==in.length()) {cout<< "小数点后无数字,表达式无效\n";return 1; }
        }
        else{
            if(ch=='('){
                if (i!=0&& (isnumber(in[i-1]) || in[i-1] == ')')) {cout<< "数字与括号、括号与括号之间无运算符,表达式无效\n";return 1;}
                oper.push('(');
            }
            else if(ch==')'){
                if(i==0) {cout<< "右括号前无内容,表达式无效\n";return 1;}
                if(isoperator(in[i-1]) && in[i-1] != ')') {cout<< "运算符和右括号之间无数字,表达式无效\n";return 1;}
                while (!oper.empty() && getPriority(oper.top())!=1) pop();
                if(oper.empty()){ cout<< "左括号不存在，括号不匹配,表达式无效\n";return 1;}
                oper.pop();
            }
            else{
                if(i==0||i+1==in.length()){cout<< "运算符在算式开头or末尾,表达式无效\n";return 1;}
                if(isoperator(in[i-1])&&in[i-1]!=')'){cout<< "运算符前是除了右括号之外的运算符,表达式无效\n";return 1;}
                while(!oper.empty()&&getPriority(oper.top())>=getPriority(ch)) pop();
                oper.push(ch);
            }    
        }
    }
    while (!oper.empty() && getPriority(oper.top())!=1) pop();
    if(!oper.empty()) {cout<< "有多余的左括号,括号不匹配,表达式无效\n";return 1;}
    return num.top();
}


int main(){
    double result;
    while(getline(cin,s)){
        result=calculator(s);
        cout<< s <<"="<< result <<endl;
    }
}


























